let axios

const requests = {
    user: {
        login: data => axios.post('user/login',data),
        register: data => axios.post('user/register', data),
        info: () => axios.get('user/info'),
        manager: {
            lock: id => axios.post(`user/${id}/lock`),
            unlock: id => axios.post(`user/${id}/unlock`),
        }
    },
    message: {
        list: params => axios.get('message/list', { params }),
        create: data => axios.post('message/create', data),
        modify: data => axios.post('message/modify', data),
        manager: {
            reply: data => axios.post('message/reply', data),
            delete: id => axios.delete(`message/${id}`)
        }
    }
}

export function useRequests() {
    return requests
}

export default {
    install: (app, axiosInstance) => {
        axios = axiosInstance
        app.config.globalProperties.requests = requests
    }
}
